package com.kdgz.kdgz.sevice.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kdgz.kdgz.beans.Staff;
import com.kdgz.kdgz.mapper.StaffMapper;
import com.kdgz.kdgz.sevice.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Desc
 * @date 2021/3/17
 */
@Service
public class StaffServiceImpl implements StaffService {

    @Autowired
    StaffMapper staffMapper;

    @Override
    public Staff login(Staff staff) {
        // 验证用户名和密码是否正确
        return staffMapper.getOneStaff(staff);
    }
    @Override
    public Integer register(Staff staff) {
        return staffMapper.insert(staff);
    }

    @Override
    public List<Staff> list() {
        return staffMapper.getAllStaff();
    }

    @Override
    public Integer getStaffCount() {
        return staffMapper.selectCount(null);
    }

    @Override
    public Integer getStatusCount(Integer status) {
        QueryWrapper<Staff> wrapper = new QueryWrapper<>();
        wrapper.eq("status",status);
        return staffMapper.selectCount(wrapper);
    }

    @Override
    public Integer updateStaff(Staff staff) {
        return staffMapper.updateById(staff);
    }

    @Override
    public Integer deleteStaff(Integer id) {
        return staffMapper.deleteById(id);
    }

    @Override
    public BigDecimal getTotalSalary() {
        return staffMapper.getTotalSalary();
    }

    @Override
    public Staff getStaffBySid(Integer sid) {
        return staffMapper.getStaffBySid(sid);
    }

    @Override
    public List<Staff> getStaffByAid(Integer aid) {
        return staffMapper.getStaffByAid(aid);
    }

    @Override
    public List<Staff> getOrderStaff() {
        return staffMapper.getOrderStaff();
    }

    @Override
    public List<Staff> getBackOfficeStaff() {
        return staffMapper.getBackOfficeStaff();
    }

    @Override
    public List<Staff> getFinanceStaff() {
        return staffMapper.getFinanceStaff();
    }
}
